package collision;


import java.awt.Image;
import java.awt.Rectangle;
import javax.swing.ImageIcon;

public abstract class Thing {

    private int x;
    private int y;
    private int width;
    private int height;
    
    private boolean visible;
    private Image image;


    /**
     * Thing Constructor
     *
     * @param  imageName 	The name or file path of the image this object displays
     */
    public Thing(String imageName) {
        ImageIcon ii = new ImageIcon(this.getClass().getResource(imageName));
        image = ii.getImage();
        width = image.getWidth(null);
        height = image.getHeight(null);
        visible = true;
        x = 40;
        y = 400;

    }
    
    /**
     * Thing Constructor
     *
     * @param  X  			initial position x
     * @param  Y  			initial position y
     * @param  imageName 	The name or file path of the image this object displays
     */
    public Thing(int X, int Y, String imageName) {
        ImageIcon ii = new ImageIcon(this.getClass().getResource(imageName));
        image = ii.getImage();
        width = image.getWidth(null);
        height = image.getHeight(null);
        visible = true;
        x = X;
        y = Y;

    }
    
    /**
     * Set the position of the object in pixels.
     *
     * @param  px  			position x
     * @param  py  			position y
     */
    public void setPosition(int px, int py)
    {
    	x = px;
    	y = py;
    }
        
    /**
     * Get the x position in pixels this Thing object
     * 
     * @return 	the x position.
     */
    public int getX() {
        return x;
    }
    
    /**
     * Get the y position in pixels this Thing object
     * 
     * @return 	the y position.
     */
    public int getY() {
        return y;
    }
    
    /**
     * Get the height in pixels of the image or graphics object that this Thing represents.
     * 
     * @return 	the height in pixels.
     */
    public int getHeight() {
        return height;
    }
    
    /**
     * Get the width in pixels of the image or graphics object that this Thing represents.
     * 
     * @return 	the width in pixels.
     */
    public int getWidth() {
        return width;
    }

    /**
     * Get the image that this Thing represents.
     * 
     * @return 	the image.
     */
    public Image getImage() {
        return image;
    }

    /**
     * Set weather or not this object is visible in the game.
     * 
     * @param v 	true if it is visible false if it is not.
     */
    public void setVisible(boolean v) {
        visible = v;
    }

    /**
     * get weather or not this object is visible in the game.
     * 
     * @return 	true if it is visible false if it is not.
     */
    public boolean isVisible() {
        return visible;
    }

    /**
     * Get the boundaries of this object in terms of pixels in the form of a rectangle
     * 
     * @return 	the rectangle that surrounds this object.
     */
    public Rectangle getBounds() {
        return new Rectangle(x, y, width, height);
    }


}
